package com.cinematicketscaning.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import com.cinematicketscaning.app.R;
import com.cinematicketscaning.app.bean.MovieItem;
import com.cinematicketscaning.app.databinding.AdapterMovieInfoBinding;

import java.util.List;

public class MovieInfoAdapter extends RUBaseAdapter<MovieItem> {
    public MovieInfoAdapter(Context context, List<MovieItem> datas) {
        super(context, datas);
    }

    @Override
    protected View initView(int position, View convertView, ViewGroup parent) {
        AdapterMovieInfoBinding binding = null;
        if (convertView == null) {
            binding = DataBindingUtil.inflate(inflater, R.layout.adapter_movie_info, parent, false);
            convertView = binding.getRoot();
            convertView.setTag(binding);
        } else {
            binding = (AdapterMovieInfoBinding)convertView.getTag();
        }
        if (getItem(position).isSelected()) {
            binding.getRoot().setBackgroundColor(context.getResources().getColor(R.color.bg_gray));
        } else {
            binding.getRoot().setBackgroundColor(context.getResources().getColor(R.color.white));
        }

        return convertView;
    }
}
